<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('test','IndexController@test');
Route::any('wechat',   'WechatController@serve');
Route::any('create-menu',   'WechatController@createMenu');

Route::any('upload',	   'UploadController@upload');
Route::any('upload-base64','UploadController@uploadBase64');


Route::get('logout',   'LoginController@logOut');


Route::middleware(['wechat.oauth'])->group(function(){
	Route::get('login',    'LoginController@login');
 	Route::any('logindo', 'LoginController@loginDo');
});


Route::middleware(['web','wechat.oauth'])->prefix('user')->namespace('User')->group(function(){
//Route::middleware(['web','checkUser','wechat.oauth'])->prefix('user')->namespace('User')->group(function(){

	Route::prefix('task')->group(function(){
		Route::get('create', 'TaskController@create');
		Route::post('save',  'TaskController@save');
		Route::any('complete','TaskController@complete');
		Route::get('show/{id}',  'TaskController@show');
		Route::get('edit/{id}',  'TaskController@edit');
		
		
		
		// 报修任务处理		
		Route::any('process-show','TaskController@processShow');
		// 报修任务完成
		Route::any('process-result','TaskController@processResult');

		Route::any('comment',       'TaskController@comment');
		Route::any('refund',      'TaskController@refund');
		Route::any('/',		      'TaskController@index');	
	});
	
	Route::get('/',        'IndexController@index');
});

Route::prefix('zadmin')->namespace('Admin')->group(function(){
	Route::middleware('checkAdmin')->group(function(){
		Route::get('test','IndexController@test');
		Route::get('system-info','SystemController@info');
		Route::get('system-update','SystemController@update');
		Route::prefix('task')->group(function(){
			
			Route::get('show/{id}',  'TaskController@show');
			Route::get('print/{id}',  'TaskController@print');
			Route::get('check/{id}', 'TaskController@check');
			
			Route::get('add',        'TaskController@add');
			Route::post('save',      'TaskController@save');
			Route::get('buyer-task/{task_id}',   'TaskController@buyerTask');
			Route::get('del/{id}',   'TaskController@del');

			// 导出
			Route::get('export','TaskController@export');
			// 回复任务
			Route::any('reply', 'TaskController@reply');
			Route::get('/','TaskController@index');
		});

		
		Route::resource('admins',     'AdminController');
		Route::resource('users',      'UserController');
		Route::resource('roles',      'RoleController');
		Route::resource('menus',      'MenuController');
		Route::resource('depart',     'DepartController');
		Route::resource('services',   'ServiceController');
		Route::get('menus/permission/{menu_id}', 'MenuController@menuPermission');
		Route::resource('permissions', 'PermissionController');	
		Route::resource('category',   'CategoryController');	

		// 工种管理
		Route::resource('worktype',   'WorktypeController');	

		
		Route::post('save-wxusers','UserController@saveWxuser');
		

		Route::prefix('wechat')->group(function(){

			Route::get('users',      'UserController@wechatUsers');
			Route::get('wxuser/pull',  'WxuserController@pull');
			Route::get('wxuser/import',  'WxuserController@import');
	Route::post('wxuser/save-user','WxuserController@saveToUser');
			Route::resource('wxuser',  'WxuserController');
			Route::get('msgtpl',     'MsgtplController@index');
			Route::get('msgtpl-show/{tpl_key}','MsgtplController@show');
			Route::get('msgtpl-edit/{tpl_key}','MsgtplController@edit');
			Route::post('msgtpl-save',         'MsgtplController@save');
			Route::get('msgtpl-del/{tpl_key}', 'MsgtplController@del');
			Route::get('msgtpl-import','MsgtplController@import');
			Route::get('msgtpl-all','MsgtplController@all');
			Route::get('menu','WxMenuController@index');

			// 素材管理
			Route::any('get-material','WxMaterialController@getMaterial');

			Route::get('material-downvideo','WxMaterialController@downVideo');

			// 发送消息到个人
			Route::any('send-msg','WxMsgController@sendMsg');
		});


		
		

		// 统计报表
		Route::prefix('census')->group(function(){
			Route::any('worker-count','CensusController@workerCount');
			Route::any('worker-count-export','CensusController@workerCountExport');
		});

		// 服务信息
		Route::resource('notice','NoticeController');
		Route::resource('worklog','WorklogController');
		Route::resource('worker','WorkerController');

		
		//退单 
		Route::post('refund','IndexController@refund');

		//派工
		Route::post('process','IndexController@process');

		//后台首页
		Route::get('/',		   'IndexController@index');
		
	});
		Route::get('login',    'LoginController@login');
		Route::post('logindo', 'LoginController@loginDo');
		Route::get('logout',   'LoginController@logOut');
		
	
});






